package com.example.iotest.bio;

import lombok.extern.slf4j.Slf4j;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

@Slf4j
public class Client01 {
    public static void main(String[] args) throws IOException {
        Socket socket=new Socket("192.168.1.28",8000);
        InputStream inputStream = socket.getInputStream();
        FileOutputStream fileOutputStream=new FileOutputStream("I:\\test.mp4");
        byte[] buffer=new byte[1024];
        int length;
        System.out.println(inputStream.available());
        log.info("开始下载");
        while ((length=inputStream.read(buffer))!=-1){
            fileOutputStream.write(buffer,0,length);
        }
        inputStream.close();
        fileOutputStream.close();
        socket.close();
        log.info("文件下载成功!");
    }
}
